package com.xuzz.study.springbootdemo.listener;

import com.xuzz.study.springbootdemo.event.DataLoadedEvent;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.event.EventListener;
import org.springframework.stereotype.Component;

@Slf4j
@Component
public class DataLoadedEventListener {
    /**
     * 除了使用@EventListener注解外，也可以使用ApplicationiListener<Event>来使用：
     * @Component
     * @Slf4j
     * public class DataLoadedEventListener implements ApplicationListener<DataLoadedEvent> {     *
     *      * 原始方式实现，用户注册监听
     *      * 实现接口后需要使用@Component注解来声明该监听需要被Spring注入管理，DataLoadedEvent，监听程序会自动调用onApplicationEvent方法    *
     *
    @Override
    public void onApplicationEvent(DataLoadedEvent dataLoadedEvent) {
     *}
     *
}
     * @param dataLoadedEvent
     */

    @EventListener
    public void afterDataLoaded(DataLoadedEvent dataLoadedEvent)
    {
        System.out.println("data loaded event arised ...");
    }
}
